package com.xian.scala.batch

/**
 * 从集合读取数据
 */

import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
import org.apache.flink.streaming.api.scala._


// 定义样例类，传感器 id ，时间戳，温度
case class SensorReading(id: String, timestamp: Long, temperature: Double)

object Sensor {
  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    val stream1 = env.fromCollection(List(
      SensorReading("sensor-1", 1547718199, 35.4),
      SensorReading("sensor-2", 1547718205, 38.1),
      SensorReading("sensor-5", 1547718201, 23.1),
      SensorReading("sensor-8", 1547718188, 19.1),
      SensorReading("sensor-3", 1547718211, 10.8)
    ))

    stream1.print()

    //执行流任务
    env.execute()

  }

}
